import numpy as np

def gaussian_kernel(distance_matrix, sigma):
    return np.exp(-distance_matrix / (2 * sigma ** 2))
# temp_dist = np.array([[0.5, 1, 2],
#                      [0.7, 4, 3],
#                      [2, 3, 0.6]]
#                      )
temp_dist = np.array([[2.2796936e+00, 1.4185905e-04, 2.1287000e+00, 1.8230720e+00, 2.0047464e+00, 1.9925015e+00],
                        [1.8264387e+00, 2.2247264e+00, 2.1148393e+00, 1.8682027e+00, 2.1857731e+00, 2.0481849e+00],
                        [2.1379218e+00, 1.7820594e+00, 1.9546708e+00,  2.1857350e+00, 2.2835042e+00, 2.2263017e+00],
                        [1.7801874e+00, 1.9467703e+00, 1.7516470e+00,  1.5445557e+00, 2.1465287e+00, 1.7326559e+00],
                        [1.3039300e+00, 1.8856990e+00, 2.0850537e+00,  1.8263741e+00, 1.9664614e+00, 1.2030802e+00],
                        [6.8809760e-01, 1.9833440e+00, 2.0243869e+00,  2.1859434e+00, 2.1319501e+00, 1.6423464e-03]])

temp_min = np.min(temp_dist, axis=1)
index1 = np.where(temp_min < 0.6)[0]

weight1 = temp_dist[index1,:].mean(axis=0)
weight1 = 1.0/(weight1 + 0.01)
weight1 = weight1/np.sum(weight1)

gaus_dist = gaussian_kernel(temp_dist, sigma=0.9)
gaus_max = np.max(gaus_dist, axis=1)
index2 = np.where(gaus_max > 0.6)[0]

weight2 = gaus_dist[index2,:].mean(axis=0)
weight2 = weight2/np.sum(weight2)

print(gaus_dist)
print('------temp------')
print(temp_min)
print(index1)
print(weight1)
print('------gaus-------')
print(gaus_max)
print(index2)
print(weight2)


